package com.ibuonline.b2b.entity;

import java.io.Serializable;

import com.ibuonline.b2b.common.SysCache;

public class ShopTemplateCategory implements Serializable {

	private static final long serialVersionUID = 4936061831082217932L;

	//fields
	private java.lang.Integer templateId;
	private java.lang.Integer catId;

	//default constructor
	public ShopTemplateCategory() {
	}

	//constructor with arguments
	public ShopTemplateCategory(java.lang.Integer catId, java.lang.Integer templateId) {
		this.catId = catId;
		this.templateId = templateId;
	}

	//getter
	public java.lang.Integer getTemplateId() {
		return templateId;
	}
	public java.lang.Integer getCatId() {
		return catId;
	}

	//setter
	public void setTemplateId(java.lang.Integer templateId) {
		this.templateId = templateId;
	}
	public void setCatId(java.lang.Integer catId) {
		this.catId = catId;
	}

	//equals method
	public boolean equals(Object other) {
		if (this == other)
			return true;
		if (!(other instanceof ShopTemplateCategory))
			return false;

		final ShopTemplateCategory shopTemplateCategory = (ShopTemplateCategory)other;
		if (!this.catId.equals(shopTemplateCategory.getCatId()) || 
			!this.templateId.equals(shopTemplateCategory.getTemplateId()))
			return false;

		return true;
	}

	//hashCode method
	public int hashCode() {
		StringBuffer keys = new StringBuffer();
		keys.append(catId).append(",");
		keys.append(templateId).append(",");
		if (keys.length() > 0)
			keys.deleteCharAt(keys.length() - 1);
		return keys.toString().hashCode();
	}

	//toString method
	public String toString() {
		return new StringBuilder("ShopTemplateCategory[")
			.append("templateId=").append(templateId).append(", ")
			.append("catId=").append(catId).append("]").toString();
	}
	
	///####

	public String getCatName() {
		ProdCategory prodCat = SysCache.getCategory(catId);
		if(prodCat != null) {
			return prodCat.getName();
		} else {
			return null;
		}
	}
}